//
//  OAFinancialTableCell.m
//  OA项目
//
//  Created by innofive on 2018/5/2.
//  Copyright © 2018年 inno. All rights reserved.
//

#import "OAFinancialTableCell.h"
#import "JHRingChart.h"

@implementation OAFinancialTableCell

-(void)onAsInitAddView:(UIView *)view forViewController:(UIViewController *)ViewController forDataSource:(id)dataSource AtIndexPath:(NSIndexPath *)indexPath
{
    [super onAsInitAddView:view forViewController:ViewController forDataSource:dataSource AtIndexPath:indexPath];

}

-(void)update:(id)model forTableView:(UITableView *)tableView AtIndexPath:(NSIndexPath *)indexPath
{
    self.indexPath =indexPath;
    
    self.imageView.image = IMAGE(@"dingYue");
    
    [self setNeedsLayout];
    
}


- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end

@implementation OAFinancialTable2Cell

-(void)onAsInitAddView:(UIView *)view forViewController:(UIViewController *)ViewController forDataSource:(id)dataSource AtIndexPath:(NSIndexPath *)indexPath
{
    [super onAsInitAddView:view forViewController:ViewController forDataSource:dataSource AtIndexPath:indexPath];
    self.hasBottomLine = YES;
}



- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];
    
    // Configure the view for the selected state
}

@end

@interface OAFinancialTableHeaderView()
@property(nonatomic,strong)JHRingChart *ring;
@end
@implementation OAFinancialTableHeaderView

-(void)onAsInitAddView:(UIView *)view forViewController:(UIViewController *)ViewController forDataSource:(id)dataSource AtSection:(NSInteger)section
{
    
   JHRingChart *ring = [[JHRingChart alloc] initWithFrame:CGRectMake(0,0,kScreenW,kScreenW-kFitH(50))];
    /*        background color         */
    ring.backgroundColor = [UIColor whiteColor];
    ring.ringWidth = kFitW(40);
    ring.titleFont = kFitW(13);
    ring.titleColor = [UIColor blackColor];
    ring.chartTitle = @"asdasdasd";
    ring.xAndYLineColor = [UIColor blackColor];
    [view addSubview:ring];
    
    _ring = ring;
    
    UIButton *btn = ({
        UIButton *l = [UIButton buttonWithType:UIButtonTypeCustom];
        l.backgroundColor = [UIColor whiteColor];
        [l setNormalTitleColor:[UIColor blackColor]];
        l.titleLabel.font =kSysFont(kFitW(12));
        [l setSelectTitleColor:hexCOLOR(@"B8944D")];
        [l setNormalTitle:@"2017年1-6月合计"];
        [l setNormalImage:IMAGE(@"iconSlideDown")];
        [view addV:l];
        l;
    });
    UIButton *btn1 = ({
        UIButton *l = [UIButton buttonWithType:UIButtonTypeCustom];
        l.titleLabel.font =kSysFont(kFitW(12));
        [l setNormalTitleColor:[UIColor blackColor]];
        [l setSelectTitleColor:hexCOLOR(@"B8944D")];
        [l setNormalTitle:@"经营班子"];
        l.backgroundColor = [UIColor whiteColor];
        [l setNormalImage:IMAGE(@"iconSlideDown")];
        [view addV:l];
        l;
    });
    
    [self onMainSetSubViewFrame:^(UIView *view, CGPoint origin, CGSize size, CGPoint center) {
        
        CGFloat w = size.width/2;
        
        btn.frame = CGRectMake(0, 0,w, kFitH(50));
        [btn layoutButtonWithEdgeInsetsStyle:(MKButtonEdgeInsetsStyleRight) imageTitleSpace:3];
        
        btn1.frame = CGRectMake(w, 0,w, kFitH(50));
        [btn1 layoutButtonWithEdgeInsetsStyle:(MKButtonEdgeInsetsStyleRight) imageTitleSpace:3];
        
        ring.frame = CGRectMake(0,kFitH(50), size.width, size.height-kFitH(50));
    }];
    self.masksToBounds = YES;
}
-(void)update:(id)model forTableView:(UITableView *)tableView AtSection:(NSInteger)section
{
    _ring.valueDataArr = @[@"0.163",@"0.3",@"0.567"];

    _ring.title = @"半年累计收入\n878.535.73";
    
    _ring.fillColorArray = @[hexCOLOR(@"A7B7EF"),hexCOLOR(@"1BCBE1"),hexCOLOR(@"50E9D4")];
    
    [_ring showAnimation];
}

@end



@interface OAFinancialTableHeader2View()
@end
@implementation OAFinancialTableHeader2View

-(void)onAsInitAddView:(UIView *)view forViewController:(UIViewController *)ViewController forDataSource:(id)dataSource AtSection:(NSInteger)section
{
    [self addTarget:ViewController action:@selector(onHeaderView:)];
    
    
    self.hasTopLine = YES;
    
    self.backgroundColor = [UIColor whiteColor];
    
    self.detailTextLabel.textColor = [UIColor blackColor];
    
    self.imageView.image = IMAGE(@"iconSlideDown");
    
    WSELF(weakSelf);
    [self onMainSetSubViewFrame:^(UIView *view, CGPoint origin, CGSize size, CGPoint center) {
        [weakSelf.textLabel sizeToFit];
        
        [weakSelf.detailTextLabel sizeToFit];
        weakSelf.detailTextLabel.right = size.width-kFitW(30);
        weakSelf.detailTextLabel.centerY = size.height/2;
        
        [weakSelf.imageView sizeToFit];
        weakSelf.imageView.right =size.width-kFitW(15);
        weakSelf.imageView.centerY = size.height/2;
    }];
  
}
-(void)update:(NSDictionary *)model forTableView:(UITableView *)tableView AtSection:(NSInteger)section
{
    self.section = section;
    //@{@"title":@"一、销售费用",@"title1":@"-301.886.29"},
    self.textLabel.font = kSysFont(kFitW(16));
    self.detailTextLabel.font = kSysFont(kFitW(16));
    
    self.textLabel.text = model[@"title"];
    self.detailTextLabel.text= model[@"title1"];
}

@end
